﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Member_AreaItem.aspx.cs" Inherits="Youz.CreditRepay.Manage.Sys.Member_AreaItem" %>

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2><i class="fa fa-edit"></i>代理商</h2>
            </div>
            <div class="panel-body">
                <form id="frm" class="form-horizontal" method="post" enctype="multipart/form-data" action="Sys/Handlers/Member_AreaHandler.ashx?type=save">
                    <input id="AreaID" name="AreaID" type="hidden" value="<%= WebHelper.Get("AreaID")%>" />
                    <div class="form-group">
                        <label class="control-label" for="RoleDesc">交易帐号</label>
                        <div class="controls">
                            <input type="text" id="AreaName" name="AreaName" maxlength="20" class="form-control required" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="RoleDesc">代理商</label>
                        <div class="input-group">
                            <select id="AgentsAccount" name="AgentsAccount" class="form-control">
                                <option value="">选择代理商</option>
                                <% 
                                    System.Data.DataTable dt = new Sys_AdminInfoBLL().Gets(" MemberAccount in ( SELECT MemberAccount FROM Right_MemberRole where RoleID = '959dac4c-f6d0-413c-b108-c9a329ea439a') ").Tables[0];
                                    foreach (System.Data.DataRow item in dt.Rows)
                                    {
                                %>
                                <option value="<%=item["MemberAccount"] %>"><%=item["MemberAccount"]+"/"+item["FirstName"]+""+item["LastName"] %></option>
                                <%
                                    }
                                %>
                            </select>
                            <span class="input-group-addon">
                                <a id="AdminInfoList" name="AdminInfoList" href="#">
                                    <i class="fa fa-plus btn-primary"></i>
                                </a>
                            </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="RoleDesc"><%: R(LanguageModule.Sys_Config, "Memo", "备注") %></label>
                        <div class="controls">
                            <textarea id="Memo" name="Memo" rows="3" maxlength="100" class="form-control"></textarea>
                        </div>
                    </div>
                    <div class="alert alert-danger" style="display: none;">
                        <button type="button" class="close" data-dismiss="alert">×</button><strong>Oh snap!</strong><span class="content"></span>
                    </div>
                    <div class="form-actions">
                        <button class="btn btn-success" type="submit" id="btnSubmit"><%: R(LanguageModule.M_Common, "btnSubmit", "保存修改") %></button>
                        <button class="btn btn-default" type="button" id="btnCancel"><%: R(LanguageModule.M_Common, "btnCancel", "取消") %></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">

    var flag = false;

    function validate() {

        return $("#frm").valid();
    };

    function get() {
        $.post("Sys/Handlers/Member_AreaHandler.ashx?type=get", { AreaID: "<%= WebHelper.Get("AreaID") %>" }, function (data) {
            $('#frm').fill(data);
            $("#Memo").val(data.Memo);
            $("#AgentsAccount").val(data.AgentsAccount);
        }, 'json');
    }

    $(function () {
        $("#frm").validate({
            errorElement: "span"
        });

        get();

        $("#frm").ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, $form, options) {
                if (flag) {
                    return false;
                }
                else {
                    flag = true;
                    return true;
                }
            },
            success: function (data) {
                if (data.isSuccess) {
                    loadPage("Sys/Member_AreaList.aspx");
                }
                else {
                    $(".alert > .content").html(data.message);
                    $(".alert").show();
                }
                flag = false;
            }
        });

        $("#btnCancel").click(function () {
            loadPage("Sys/Member_AreaList.aspx");
        });

        $("#AdminInfoList").click(function () {
            loadPage("Sys/Sys_AdminInfoList.aspx");
        });
    });

</script>
